package generator

// mapTemplate Map类型的模板
const mapTemplate = `package {{.Package}}

import (
	"fmt"

	"{{.ImportPath}}"

	"gitee.com/lovengame/kit/sea/redis"
	"gitee.com/lovengame/kit/sea/util"

	"github.com/gogo/protobuf/proto"
	l4g "github.com/ivanabc/log4go"
)

const {{.Struct.DbStructName}}ProtoBufferSize = {{.BufferSize}}

func (client {{.Struct.ClientName}}) Get{{.Struct.Name}}(
	id {{.Struct.UniqueType}}) (*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("HMGET", strKeyName, []{{.Struct.UniqueType}}{id})
	datas, err := client.GetSome{{.Struct.Name}}ByReply(ptReply)
	if err != nil {
		return nil, err
	}
	for _, m := range datas {
		return m, nil
	}
	return nil, nil
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}(
	ids []{{.Struct.UniqueType}}) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("HMGET", strKeyName, ids)
	return client.GetSome{{.Struct.Name}}ByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}MCall(
	ids []{{.Struct.UniqueType}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	client.Append("HMGET", strKeyName, ids)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}() (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("HVALS", strKeyName)
	return client.GetSome{{.Struct.Name}}ByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}MCall() {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	client.Append("HVALS", strKeyName)
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}ByReply(
	ptReply *redis.Reply) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	bufs, err := ptReply.ListBytes()
	if err != nil {
		l4g.Errorf("RedisOp Get {{.Struct.Name}} Error %v", err)
		return nil, err
	}
	datas := make(map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, len(bufs))
	for _, buf := range bufs {
		if len(buf) <= 1 {
			continue
		}
		if buf[0] != 0 {
			buf, err = UnCompressWithFlag(buf)
			if err != nil {
				l4g.Errorf("RedisOp UnCompress {{.Struct.Name}} Error %v", err)
				return nil, err
			}
		} else {
			buf = buf[1:]
		}
		data := &{{.Struct.PointStructName}}{}
		err = proto.Unmarshal(buf, data)
		if err != nil {
			l4g.Errorf("RedisOp Get {{.Struct.Name}} Unmarshal Error %v", err)
			return nil, err
		}
		datas[data.Get{{.Struct.UniqueName}}()] = data
	}
	return datas, nil
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}ID() ([]{{.Struct.UniqueType}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("HKEYS", strKeyName)
	return client.GetAll{{.Struct.Name}}IDByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDMCall() {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	client.Append("HKEYS", strKeyName)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDByReply(
	ptReply *redis.Reply) ([]{{.Struct.UniqueType}}, error) {

	bufs, err := ptReply.ListBytes()
	if err != nil {
		l4g.Errorf("RedisOp Get {{.Struct.Name}} ID Error %v", err)
		return nil, err
	}
	ids := make([]{{.Struct.UniqueType}}, 0, len(bufs))
	for _, buf := range bufs {

		neg := false
		if buf[0] == '-' {
			buf = buf[1:]
			neg = true
		}
		val, ok := util.ParseUint64(buf)
		if ok {
			var value {{.Struct.UniqueType}}
			{{if eq .Struct.UniqueType "uint64" -}}
			if neg {
				value = -(val)
			} else {
				value = (val)
			}
			{{else -}}
			if neg {
				value = -{{.Struct.UniqueType}}(val)
			} else {
				value = {{.Struct.UniqueType}}(val)
			}
			{{end -}}
			ids = append(ids, value)
		} else {
			l4g.Errorf("parse int64 error %s", string(buf))
			return nil, fmt.Errorf("parse int64 error %s", string(buf))
		}

	}
	return ids, nil
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}(
	datas []*{{.Struct.PointStructName}}) error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	fields := make([]interface{}, 0, len(datas)*2)
	for _, data := range datas {
		buffer := proto.NewBuffer(make([]byte, 0, {{.Struct.DbStructName}}ProtoBufferSize))
		bytes := buffer.Bytes()
		bytes = bytes[:1]
		bytes[0] = 0
		buffer.SetBuf(bytes)
		err := buffer.Marshal(data)
		if err != nil {
			l4g.Errorf("RedisOp Marshal {{.Struct.Name}} Error %v ", err)
			for _, data := range datas {
				l4g.Errorf("RedisOp Set {{.Struct.Name}} Error , Data: %+v", data)
			}
			return err
		}
		buf := buffer.Bytes()
		if len(buf) > CompressBytes {
			buf, err = CompressWithFlag(buf, CompressFlagSnappy)
			if err != nil {
				l4g.Errorf("RedisOp Compress {{.Struct.Name}} Error %v", err)
			}
		}
		fields = append(fields, data.Get{{.Struct.UniqueName}}(), buf)
	}
	ptReply := client.Cmd("HMSET", strKeyName, fields)
	if ptReply.Err != nil {
		for _, data := range datas {
			l4g.Errorf("RedisOp Set {{.Struct.Name}} Error %v, Data: %+v", ptReply.Err, data)
		}
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}MCall(
	datas []*{{.Struct.PointStructName}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	fields := make([]interface{}, 0, len(datas)*2)
	for _, data := range datas {
		buffer := proto.NewBuffer(make([]byte, 0, {{.Struct.DbStructName}}ProtoBufferSize))
		bytes := buffer.Bytes()
		bytes = bytes[:1]
		bytes[0] = 0
		buffer.SetBuf(bytes)
		err := buffer.Marshal(data)
		if err != nil {
			l4g.Errorf("RedisOp Marshal {{.Struct.Name}} Error %v", err)
			for _, data := range datas {
				l4g.Errorf("RedisOp Set {{.Struct.Name}} Error , Data: %+v", data)
			}
		}
		buf := buffer.Bytes()
		if len(buf) > CompressBytes {
			buf, err = CompressWithFlag(buf, CompressFlagSnappy)
			if err != nil {
				l4g.Errorf("RedisOp Compress {{.Struct.Name}} Error %v", err)
			}
		}
		if err == nil {
			fields = append(fields, data.Get{{.Struct.UniqueName}}(), buf)
		}
	}
	client.Append("HMSET", strKeyName, fields)
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}(
	ids []{{.Struct.UniqueType}}) error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("HDEL", strKeyName, ids)
	if ptReply.Err != nil {
		l4g.Errorf("RedisOp Rem {{.Struct.Name}} Error %v Datas %v", ptReply.Err, ids)
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}MCall(
	ids []{{.Struct.UniqueType}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	client.Append("HDEL", strKeyName, ids)
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}() error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	ptReply := client.Cmd("DEL", strKeyName)
	if ptReply.Err != nil {
		l4g.Errorf("RedisOp Del {{.Struct.Name}} Error %v", ptReply.Err)
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}MCall() {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}}
	client.Append("DEL", strKeyName)
}
`

// mapTemplate Map类型的模板
const mapTemplateWithSuffix = `package {{.Package}}

import (
	"fmt"
	"strconv"

	"{{.ImportPath}}"

	"gitee.com/lovengame/kit/sea/redis"
	"gitee.com/lovengame/kit/sea/util"

	"github.com/gogo/protobuf/proto"
	l4g "github.com/ivanabc/log4go"
)

const {{.Struct.DbStructName}}ProtoBufferSize = {{.BufferSize}}

func (client {{.Struct.ClientName}}) Get{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}, id {{.Struct.UniqueType}}) (*{{.Struct.PointStructName}}, error) {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.Get{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10), id)
	{{else -}}
	return client.Get{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10), id)
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}, ids []{{.Struct.UniqueType}}) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.GetSome{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10), ids)
	{{else -}}
	return client.GetSome{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10), ids)
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}MCallSK(
	sufKey {{.Struct.KeyType}}, ids []{{.Struct.UniqueType}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.GetSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(uint64(sufKey), 10), ids)
	{{else -}}
	client.GetSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(sufKey, 10), ids)
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.GetAll{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	return client.GetAll{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}MCallSK(
	sufKey {{.Struct.KeyType}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.GetAll{{.Struct.Name}}MCallSKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	client.GetAll{{.Struct.Name}}MCallSKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDSK(
	sufKey {{.Struct.KeyType}}) ([]{{.Struct.UniqueType}}, error) {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.GetAll{{.Struct.Name}}IDSKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	return client.GetAll{{.Struct.Name}}IDSKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDMCallSK(
	sufKey {{.Struct.KeyType}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.GetAll{{.Struct.Name}}IDMCallSKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	client.GetAll{{.Struct.Name}}IDMCallSKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}, datas []*{{.Struct.PointStructName}}) error {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.SetSome{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10), datas)
	{{else -}}
	return client.SetSome{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10), datas)
	{{end -}}
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}MCallSK(
	sufKey {{.Struct.KeyType}}, datas []*{{.Struct.PointStructName}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.SetSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(uint64(sufKey), 10), datas)
	{{else -}}
	client.SetSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(sufKey, 10), datas)
	{{end -}}
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}, ids []{{.Struct.UniqueType}}) error {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.RemSome{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10), ids)
	{{else -}}
	return client.RemSome{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10), ids)
	{{end -}}
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}MCallSK(
	sufKey {{.Struct.KeyType}}, ids []{{.Struct.UniqueType}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.RemSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(uint64(sufKey), 10), ids)
	{{else -}}
	client.RemSome{{.Struct.Name}}MCallSKs(strconv.FormatUint(sufKey, 10), ids)
	{{end -}}
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}SK(
	sufKey {{.Struct.KeyType}}) error {

	{{if ne .Struct.KeyType "uint64" -}}
	return client.DelAll{{.Struct.Name}}SKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	return client.DelAll{{.Struct.Name}}SKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}MCallSK(
	sufKey {{.Struct.KeyType}}) {

	{{if ne .Struct.KeyType "uint64" -}}
	client.DelAll{{.Struct.Name}}MCallSKs(strconv.FormatUint(uint64(sufKey), 10))
	{{else -}}
	client.DelAll{{.Struct.Name}}MCallSKs(strconv.FormatUint(sufKey, 10))
	{{end -}}
}

//=========================以下是具体实现=========================

func (client {{.Struct.ClientName}}) Get{{.Struct.Name}}SKs(
	sufKey string, id {{.Struct.UniqueType}}) (*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("HMGET", strKeyName, []{{.Struct.UniqueType}}{id})
	datas, err := client.GetSome{{.Struct.Name}}ByReply(ptReply)
	if err != nil {
		return nil, err
	}
	for _, m := range datas {
		return m, nil
	}
	return nil, nil
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}SKs(
	sufKey string, ids []{{.Struct.UniqueType}}) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("HMGET", strKeyName, ids)
	return client.GetSome{{.Struct.Name}}ByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}MCallSKs(
	sufKey string, ids []{{.Struct.UniqueType}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	client.Append("HMGET", strKeyName, ids)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}SKs(
	sufKey string) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("HVALS", strKeyName)
	return client.GetSome{{.Struct.Name}}ByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}MCallSKs(
	sufKey string) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	client.Append("HVALS", strKeyName)
}

func (client {{.Struct.ClientName}}) GetSome{{.Struct.Name}}ByReply(
	ptReply *redis.Reply) (map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, error) {

	bufs, err := ptReply.ListBytes()
	if err != nil {
		l4g.Errorf("RedisOp Get {{.Struct.Name}} Error %v", err)
		return nil, err
	}
	datas := make(map[{{.Struct.UniqueType}}]*{{.Struct.PointStructName}}, len(bufs))
	for _, buf := range bufs {
		if len(buf) <= 1 {
			continue
		}
		if buf[0] != 0 {
			buf, err = UnCompressWithFlag(buf)
			if err != nil {
				l4g.Errorf("RedisOp UnCompress {{.Struct.Name}} Error %v", err)
				return nil, err
			}
		} else {
			buf = buf[1:]
		}
		data := &{{.Struct.PointStructName}}{}
		err = proto.Unmarshal(buf, data)
		if err != nil {
			l4g.Errorf("RedisOp Get {{.Struct.Name}} Unmarshal Error %v", err)
			return nil, err
		}
		datas[data.Get{{.Struct.UniqueName}}()] = data
	}
	return datas, nil
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDSKs(
	sufKey string) ([]{{.Struct.UniqueType}}, error) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("HKEYS", strKeyName)
	return client.GetAll{{.Struct.Name}}IDByReply(ptReply)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDMCallSKs(
	sufKey string) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	client.Append("HKEYS", strKeyName)
}

func (client {{.Struct.ClientName}}) GetAll{{.Struct.Name}}IDByReply(
	ptReply *redis.Reply) ([]{{.Struct.UniqueType}}, error) {

	bufs, err := ptReply.ListBytes()
	if err != nil {
		l4g.Errorf("RedisOp Get {{.Struct.Name}} ID Error %v", err)
		return nil, err
	}
	ids := make([]{{.Struct.UniqueType}}, 0, len(bufs))
	for _, buf := range bufs {

		{{if eq .Struct.UniqueType "string" -}}
		ids = append(ids, {{.Struct.UniqueType}}(buf))
		{{else -}}
		neg := false
		if buf[0] == '-' {
			buf = buf[1:]
			neg = true
		}
		val, ok := util.ParseUint64(buf)
		if ok {
			var value {{.Struct.UniqueType}}
			{{if eq .Struct.UniqueType "uint64" -}}
			if neg {
				value = -(val)
			} else {
				value = (val)
			}
			{{else -}}
			if neg {
				value = -{{.Struct.UniqueType}}(val)
			} else {
				value = {{.Struct.UniqueType}}(val)
			}
			{{end -}}
			ids = append(ids, value)
		} else {
			l4g.Errorf("parse int64 error %s", string(buf))
			return nil, fmt.Errorf("parse int64 error %s", string(buf))
		}
		{{end}}

	}
	return ids, nil
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}SKs(
	sufKey string, datas []*{{.Struct.PointStructName}}) error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	fields := make([]interface{}, 0, len(datas)*2)
	for _, data := range datas {
		buffer := proto.NewBuffer(make([]byte, 0, {{.Struct.DbStructName}}ProtoBufferSize))
		bytes := buffer.Bytes()
		bytes = bytes[:1]
		bytes[0] = 0
		buffer.SetBuf(bytes)
		err := buffer.Marshal(data)
		if err != nil {
			l4g.Errorf("RedisOp Marshal {{.Struct.Name}} Error %v ", err)
			for _, data := range datas {
				l4g.Errorf("RedisOp Set {{.Struct.Name}} Error , Data: %+v", data)
			}
			return err
		}
		buf := buffer.Bytes()
		if len(buf) > CompressBytes {
			buf, err = CompressWithFlag(buf, CompressFlagSnappy)
			if err != nil {
				l4g.Errorf("RedisOp Compress {{.Struct.Name}} Error %v", err)
			}
		}
		fields = append(fields, data.Get{{.Struct.UniqueName}}(), buf)
	}
	ptReply := client.Cmd("HMSET", strKeyName, fields)
	if ptReply.Err != nil {
		for _, data := range datas {
			l4g.Errorf("RedisOp Set {{.Struct.Name}} Error %v, Data: %+v", ptReply.Err, data)
		}
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) SetSome{{.Struct.Name}}MCallSKs(
	sufKey string, datas []*{{.Struct.PointStructName}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	fields := make([]interface{}, 0, len(datas)*2)
	for _, data := range datas {
		buffer := proto.NewBuffer(make([]byte, 0, {{.Struct.DbStructName}}ProtoBufferSize))
		bytes := buffer.Bytes()
		bytes = bytes[:1]
		bytes[0] = 0
		buffer.SetBuf(bytes)
		err := buffer.Marshal(data)
		if err != nil {
			l4g.Errorf("RedisOp Marshal {{.Struct.Name}} Error %v", err)
			for _, data := range datas {
				l4g.Errorf("RedisOp Set {{.Struct.Name}} Error , Data: %+v", data)
			}
		}
		buf := buffer.Bytes()
		if len(buf) > CompressBytes {
			buf, err = CompressWithFlag(buf, CompressFlagSnappy)
			if err != nil {
				l4g.Errorf("RedisOp Compress {{.Struct.Name}} Error %v", err)
			}
		}
		if err == nil {
			fields = append(fields, data.Get{{.Struct.UniqueName}}(), buf)
		}
	}
	client.Append("HMSET", strKeyName, fields)
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}SKs(
	sufKey string, ids []{{.Struct.UniqueType}}) error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("HDEL", strKeyName, ids)
	if ptReply.Err != nil {
		l4g.Errorf("RedisOp Rem {{.Struct.Name}} Error %v Datas %v", ptReply.Err, ids)
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) RemSome{{.Struct.Name}}MCallSKs(
	sufKey string, ids []{{.Struct.UniqueType}}) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	client.Append("HDEL", strKeyName, ids)
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}SKs(
	sufKey string) error {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	ptReply := client.Cmd("DEL", strKeyName)
	if ptReply.Err != nil {
		l4g.Errorf("RedisOp Del {{.Struct.Name}} Error %v", ptReply.Err)
		return ptReply.Err
	}
	return nil
}

func (client {{.Struct.ClientName}}) DelAll{{.Struct.Name}}MCallSKs(
	sufKey string) {

	strKeyName := RedisOpKeyMap{{.Struct.DbStructName}} + sufKey
	client.Append("DEL", strKeyName)
}
`
